<?php
/**
 * index page
 *
 * @author Jensen
 */
class index extends AbstractAction {

    public function run() {
        global $TPL;

//        $itemDAO = new BTItemsDAO();
//
//        $cids = array(
//            '1' => array('name' => '美剧'),
//            '5' => array('name' => '电影'),
//            '26' => array('name' => '韩剧'),
//            '21' => array('name' => '日剧'),
//        );
//
//        $TPL->assign('cids', $cids);
//        foreach ($cids as $cid => $cname) {
//            $items = $itemDAO->GetItemsByCategoryId($cid, INDEX_PERPAGE, 1, true);
//            $cids[$cid]['items'] = $items;
//        }
        
        $dao = new MovieDAO();
        // 最近更新电影
        $hotmovies = $dao->GetAllItemByType(2);
//        $hotmovies = array_chunk($hotmovies, 6);
        foreach( $hotmovies as &$itemInfo ){
            $itemInfo['largeImgUrl'] = $this->getLargeImgUrl( $itemInfo['imgUrl'] );
        }
        // 最近更新电视剧
        $hottvs = $dao->GetAllItemByType(1);
//        $hottvs = array_chunk($hottvs, 6);
        foreach( $hottvs as &$itemInfo ){
            $itemInfo['largeImgUrl'] = $this->getLargeImgUrl( $itemInfo['imgUrl'] );
        }
        
        // 首页推荐
//        $recommends = $dao->GetAllItemByType(2, 4);
//        foreach( $recommends as &$itemInfo ){
//            $itemInfo['largeImgUrl'] = $this->getLargeImgUrl( $itemInfo['imgUrl'] );
//        }
        
        // get search history
        $searchHistoryDao = new SearchHistoryDAO();
        $searchhistory = $searchHistoryDao->GetAllItems();
        $TPL->assign('searchhistory', $searchhistory );
        
        $TPL->assign('hotmovies', $hotmovies);
        $TPL->assign('hottvs', $hottvs);
//        $TPL->assign('recommends', $recommends);
        $TPL->assign('filters', $this->getFilterValues() );
        $TPL->assign('current_page', 'index');
        $TPL->display('theme_v2/index.tpl');
    }

}

?>
